import { buildColumns } from '@/utils/table'
export default function useTableColumn() {
  const columns = computed(() =>
    buildColumns([
      {
        title: '类型',
        width: 100,
        render: ({ record }) => {
          return record.bind_operation === 1 ? '绑定' : '解绑'
        }
      },
      {
        title: '机器码',
        width: 630,
        dataIndex: 'device_fingerprint',
        slotName: 'device_fingerprint'
        // format: 'copy'
      },
      {
        title: '操作人',
        width: 103,
        render: ({ record }) => {
          return record.role === 1 ? '管理员' : '用户'
        }
      },
      {
        title: '时间',
        width: 180,
        dataIndex: 'created_at',
        slotName: 'created_at',
        format: 'date-time',
        sortable: sortableSettings,
        fixed: 'right'
      }
    ])
  )
  const fields = ref([
    {
      label: '用户账号',
      value: '',
      key: 'username',
      span: 1
    },
    {
      label: '授权码',
      value: '',
      key: 'key'
    },
    {
      label: '绑定状态',
      value: 1,
      key: 'bind_status'
    },
    {
      label: '到期时间',
      value: '',
      key: 'expired_at'
    },
    {
      label: '添加时间',
      value: '',
      key: 'created_at'
    },
    {
      label: '主控 IP',
      value: '',
      key: 'ip'
    },
    {
      label: '主控版本',
      value: '',
      key: 'client_version'
    },
    {
      label: '节点数',
      value: 0,
      key: 'node_count'
    },
    {
      label: '站点数',
      value: 0,
      key: 'site_count'
    },
    {
      label: '启用状态',
      value: 1,
      key: 'status'
    },
    {
      label: '备注',
      value: '',
      key: 'remark',
      span: 2
    },
    {
      label: '机器码',
      value: '',
      key: 'device_fingerprint',
      span: 3
    }
  ])
  return { columns, fields }
}
